home *** CD-ROM | disk | FTP | other *** search
- Path: Rezonet.net!news
- From: ray@ultimate-tech.com (Ray Dunn)
- Newsgroups: comp.lang.c
- Subject: Re: quick decision: is n a power of 2?
- Date: 29 Jan 1996 14:03:14 GMT
- Organization: Ultimate Technographics Inc.
- Message-ID: <4eik32$15mb@ns.RezoNet.NET>
- References: <Pine.OSF.3.91.960119114608.18779E-100000@io.UWinnipeg.ca> <TANMOY.96Jan21104404@qcd.lanl.gov> <4e6rs0$dvl@ns.RezoNet.NET> <9601251245.AA12220@dxmint.cern.ch> <822791542snz@genesis.demon.co.uk>
- NNTP-Posting-Host: 204.19.230.7
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- In referenced article, Lawrence Kirby says...
- >Two's complement is a representation for signed integers so
- >unsigned arithmetic clearly doesn't use it. However the nice thing
- >about 2's complement arithmetic is that in most instances the
- >underlying bit manipulations are (or can be for a suitable definition
- >of overflow behaviour) the same as those for unsigned arithmetic (so
- >at the archetecture level a single form of, e.g. an ADD instruction,
- >can deal with both).
- >
- >So the expression (-5) and (-5U) are each evaluated by its own set of
- >rules but where signed integers are represented in 2's complement the
- >2 results will have the same underlying bit pattern.
-
- So what would you call this operation that is being done on the
- unsigned int?
-
- I really think you're nit-picking unnecessarily here, so let me
- nit-pick back... (:-)
-
- Dan Pop's assertion that unary minus does a two's complement negate on
- unsigned types in 'C' was a perfectly reasonable statement.
-
- A two's complement negate is a bitwise operation on a set of bits, just
- like a one's complement negate is. The signedness of that set of bits
- is irrelvant to the operation, like any other, it is only the
- subsequent interpretation of the sign bit that matters.
- --
- Ray Dunn (opinions are my own) | Phone: (514) 938 9050
- Montreal | Phax : (514) 938 5225
- ray@ultimate-tech.com | Home : (514) 630 3749
-
-